<?php

/**
 * Subcontract filter form base class.
 *
 * @package    seth
 * @subpackage filter
 * @author     Fuz
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseSubcontractFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'plant'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plant'), 'add_empty' => true)),
      'supplier' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Supplier'), 'add_empty' => true)),
      'type'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'fee'      => new sfWidgetFormFilterInput(),
      'start'    => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'end'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'note'     => new sfWidgetFormFilterInput(),
      'name'     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'status'   => new sfWidgetFormFilterInput(),
      'payments' => new sfWidgetFormFilterInput(),
    ));

    $this->setValidators(array(
      'plant'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Plant'), 'column' => 'id')),
      'supplier' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Supplier'), 'column' => 'id')),
      'type'     => new sfValidatorPass(array('required' => false)),
      'fee'      => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'start'    => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'end'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
      'note'     => new sfValidatorPass(array('required' => false)),
      'name'     => new sfValidatorPass(array('required' => false)),
      'status'   => new sfValidatorPass(array('required' => false)),
      'payments' => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('subcontract_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Subcontract';
  }

  public function getFields()
  {
    return array(
      'id'       => 'Number',
      'plant'    => 'ForeignKey',
      'supplier' => 'ForeignKey',
      'type'     => 'Text',
      'fee'      => 'Number',
      'start'    => 'Date',
      'end'      => 'Date',
      'note'     => 'Text',
      'name'     => 'Text',
      'status'   => 'Text',
      'payments' => 'Text',
    );
  }
}
